package action;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.opensymphony.xwork2.ActionSupport;

import bean.DB;

public class ConfigAction extends ActionSupport {
	
	private String task_interval;
	private String page_count;
	private String time_threshold;
	private String size_lower_limit;
	private String size_topper_limit;
	private boolean teacher_clean_power;
	
	private String feedback;
	

	Connection con=null;
	PreparedStatement pst=null;
	int n=0;
	
	public String config() throws SQLException{
		DB db=new DB();
		con=db.getCon();
		String sql="update systemconfig set task_interval=? , page_count=? , time_threshold=? , size_lower_limit=? , size_topper_limit=? , teacher_clean_power=? ";
		pst=con.prepareStatement(sql);
		pst.setString(1, task_interval);
		pst.setString(2, page_count);
		pst.setString(3, time_threshold);
		pst.setString(4, size_lower_limit);
		pst.setString(5, size_topper_limit);
		pst.setBoolean(6, teacher_clean_power);
		System.out.println(teacher_clean_power);
		//System.out.println("1"+sql);
		n=pst.executeUpdate();
		//System.out.println("2"+sql);
		if(n>0){
			this.feedback="success";
			//System.out.println(feedback);
			pst.close();
			con.close();
			return SUCCESS;
		}
		//System.out.println("jjjjjjjjjjjjjjjj");
		pst.close();
		con.close();
		return ERROR;
	}
	
	
	public String getTask_interval() {
		return task_interval;
	}

	public void setTask_interval(String task_interval) {
		this.task_interval = task_interval;
	}

	public String getPage_count() {
		return page_count;
	}

	public void setPage_count(String page_count) {
		this.page_count = page_count;
	}

	public String getTime_threshold() {
		return time_threshold;
	}

	public void setTime_threshold(String time_threshold) {
		this.time_threshold = time_threshold;
	}

	public String getSize_lower_limit() {
		return size_lower_limit;
	}

	public void setSize_lower_limit(String size_lower_limit) {
		this.size_lower_limit = size_lower_limit;
	}

	public String getSize_topper_limit() {
		return size_topper_limit;
	}

	public void setSize_topper_limit(String size_topper_limit) {
		this.size_topper_limit = size_topper_limit;
	}

	public boolean getTeacher_clean_power() {
		return teacher_clean_power;
	}

	public void setTeacher_clean_power(boolean teacher_clean_power) {
		this.teacher_clean_power = teacher_clean_power;
	}
	

	
	public String getFeedback() {
		return feedback;
	}


	public void setFeedback(String feedback) {
		this.feedback = feedback;
	}

}
